enum codeEnum {
    success = 200, // 成功
    error = 400, // 错误
    unRegistered = 401, // 未注册
    notLoggedIn = 402, // 未登录
    registered = 403 // 已注册
}

class response {
    constructor(protected data: unknown, protected message: string, protected code: codeEnum) { }
}

class successRes extends response {
    constructor(data = {}, message = '', code = codeEnum.success) {
        super(data, message, code)
    }
}

class errorRes extends response {
    constructor(message: string | Error = '', code = codeEnum.error, data = {}) {
        if (message instanceof Error) message = message.message
        super(data, message, code)
    }
}

export {
    successRes,
    errorRes,
    codeEnum
}